<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>跑马灯</title>
</head>
<style>
    .red {
        background-color: red;
    }

    .green {
        background-color: green;
    }

</style>

<body>

<div id="app">
    <!--   <input type="button" value="红色" @click="bg='red'">
       <input type="button" value="绿色" @click="bg='green'">
       <div style=" width: 100px;height: 100px" v-bind:class="bg">
       {{bg}}
       </div>


       <input type="button" value="切换颜色" @click="flag=!flag">

       <div style=" width: 100px;height: 100px" v-bind:class="{'red':flag,'green':!flag}">
           {{bg}}
       </div>


       -->


    <input type="button" value="切换颜色" @click="flag=!flag">

    <div style=" width: 100px;height: 100px" :class="{'red':flag,'green':!flag}">

    </div>


</div>


<script src="./node_modules/vue/dist/vue.js"></script>
<script>
    let mv = new Vue({
        el: "#app",
        data: {
            bg: "red",
            flag: true

        },
        methods: {
            change() {
                this.flag = !this.flag;
            }

        }

    })


</script>


</body>
</html>